﻿
using Light.Framework.Component;
using Light.Framework.Contract;
using Light.Weixin.Contract;
using Light.Weixin.Model;
using Light.Framework.Model;

namespace Light.Weixin.Component
{
    public class WxUserInfoComponent : BaseComponent<WxUserInfo>, IWxUserInfoComponent
    {
        public WxUserInfo Get(string openid)
        {
            if (string.IsNullOrEmpty(openid))
            {
                return null;
            }
            using (new GuestUser())
            {
                return Get("OpenID", openid);
            }
        }

        protected override void BeforeSave(WxUserInfo obj)
        {
            base.BeforeSave(obj);
            obj.Organization = obj.WxApp.Organization;
        }
    }
}
